package petertel.pbx.conf.sip;

import java.util.ArrayList;
import java.util.List;

import petertel.pbx.conf.ConfigItem;
import petertel.pbx.conf.GenericConfigWriter;
import petertel.pbx.conf.NameValuePair;
import petertel.pbx.connector.Executor;

public class SipConfWriter {

	public static void write(Executor executor, SipConf sipConf) {
		List<ConfigItem> itemList = new ArrayList<ConfigItem>();
		for (Device device : sipConf.getChildren()) {
			itemList.add(device);
			for (NameValuePair prop : device.getChildren()) {
				itemList.add(prop);
			}
		}
		String filename = "/etc/asterisk/sip.conf";
		GenericConfigWriter.write(executor, itemList, filename);
	}

}
